<%--
 *  File:    OrgAccountEdit.jsp
 *  @Author: jianni 
 *  Date:    2001/12/13
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.OrgGroupEdit");    
%>

<% //--------------------------------------  variant and initialization --%>
<%
  	String strModuleName = "OGM";
  	String privilegeCode = "10107,L105";
%>
  

  
<%
  	boolean bIsEdit = false;
  	boolean bIsNewChild = false;
  	if(request.getParameter("orggroupid") != null)
  	{
    	bIsEdit = true;
  	}
  	if(request.getParameter("parentgroupid")!=null)
  	{
    	bIsNewChild = true;
  	}  
  	HashMap userInfo = (HashMap)session.getAttribute("userinfo");    
  	String orgGroupId = new String("");
  	String orgGroupCode = new String("");
  	String orgGroupName = new String("");
  	String orgGroupDesc = new String("");
  	String globalPcCode = request.getParameter("globalpccode");
  	String grade = request.getParameter("grade");
  	String parentId = "";//request.getParameter("parentid");
  	String parentName = "";//request.getParameter("parentname");
  	String isbottom = new String("Y");
  	String datelastupdated = "";
%>

<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>



<html>
<head>
<title>OrgGroupEdit</title>
<PageFlow:CheckPageFlow pageName="orggrpedit"/>  
<%@ include file="/inc/InitEdit.inc" %>


<% //--------------------------------------  output variant from pageflow --%>
<%  
	String strReadOnly = "";
	HashMap orgGroup = (HashMap)pageContext.getAttribute("orggrpinfo");
  	if(grade==null)
  	{
  		grade = "1";
  	}else
  	{
  		grade = String.valueOf((Integer.parseInt(grade)) + 1);
  	}
  	if(orgGroup != null && bIsEdit)
  	{
    	orgGroupId = (orgGroup.get("orggroupid")).toString();
    	orgGroupCode = (orgGroup.get("groupcode")).toString();
	  	orgGroupName = (orgGroup.get("groupname")).toString();
	  	orgGroupDesc = (orgGroup.get("groupdesc")==null ? "" : (String)(orgGroup.get("groupdesc")));
	  	parentId = (orgGroup.get("parentgroupid")==null ? "" : (orgGroup.get("parentgroupid")).toString());
	  	parentName = (orgGroup.get("parentgroupname")==null ? "" : (String)(orgGroup.get("parentgroupname")));
		datelastupdated = (orgGroup.get("datelastupdated")==null ? "" : (orgGroup.get("datelastupdated")).toString());  	
		isbottom=(orgGroup.get("isbottom")==null ? isbottom : (orgGroup.get("isbottom")).toString());
  	}else if(orgGroup != null && bIsNewChild) 
  	{
  		orgGroupId = "";
    	orgGroupCode = "";
	  	orgGroupName = "";
	  	orgGroupDesc = "";
	  	parentId = (orgGroup.get("orggroupid")==null ? "" : (orgGroup.get("orggroupid")).toString());
	  	parentName = (orgGroup.get("groupname")==null ? "" : (String)(orgGroup.get("groupname")));
		datelastupdated = "";  	
  	}else
  	{
  		orgGroup = new HashMap();
  	}   
 	if(datelastupdated==null || datelastupdated.length()==0)
  	{
  		datelastupdated = (new java.sql.Date((new java.util.Date()).getTime())).toString();
  	}
%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<script language="JavaScript" src="../../js/ScriptLib.js"></script>
<%@ include file="/inc/NewCalendar.inc" %>
<script language="JavaScript">
function page_done()
{
  	if(!checkNull(document.orggrpeditform))
  		return;  
  	if(!checkForm(document.orggrpeditform))
  		return;
  	emptyToNull(document.orggrpeditform);  
  	document.orggrpeditform.actionname.value = "done";
  	isRunning = true;
  	document.orggrpeditform.submit();
}
</script>
</head>

<body>
	
	<% //--------------------------------------  hidden form variant --%>
	<form name="orggrpeditform" method="post" action="../../Dispatcher" target="_parent">
    <input type="hidden" name="pagename" value="orggrpedit">
    <input type="hidden" name="actionname"> 
    <input type="hidden" name="orgid" value="<%=JspHelper.filterNull( userInfo.get("orgid"))%>"> 
    <input type="hidden" name="globalpccode" value="<%=JspHelper.filterNull( globalPcCode)%>"> 
    <input type="hidden" name="datelastupdated" value=<%=JspHelper.filterNull( datelastupdated)%>> 
    <input type="hidden" name="grade" value=<%=JspHelper.filterNull( grade)%>> 
    <input type="hidden" name="languagecode" value=<%= strLanguageCode %>> 
    <input type="hidden" name="isbottom" value="<%=JspHelper.filterNull(isbottom)%>"> 
    <%if(orgGroupId.length()!=0){%>
    	<input type="hidden" name="orggroupid" value="<%=JspHelper.filterNull( orgGroupId)%>"> 
    <%
    	strReadOnly = "readonly";
    }
    else
    {
    	strReadOnly = "";
    }%>
      
	<table width="100%" cellspacing="0" border="0" cellpadding="0">
  	<tr> 
    	<td> 
      		<table width="100%" cellspacing="0" cellpadding="0">
        	<tr> 
          		<td colspan="2" class="summary_top"></td>
        	</tr>
        	<tr> 
          		<td colspan="2"><img src="../../images/<%= strLanguageCode %>/quote.gif" width="16" height="11"> 
            		<%= label.getLabelName("L_NEGroup") + label.getLabelName("L_Colon") %></td>
        	</tr>
      		</table>
      		
      		<table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        	<tr> 
          		<td class="need" width="110"><%= label.getLabelName("L_GroupCode") + label.getLabelName("L_Colon") %></td>
          		<td> 
            		<input type="text" name="groupcode" size="15" value="<%=JspHelper.filterNull( orgGroupCode)%>" <%=JspHelper.filterNull( strReadOnly)%> isnull="N" label="<%= message.getMessageDesc("VALUE_NOT_NULL",  label.getLabelName("L_GroupCode",false)) %>">
          		</td>	
        	</tr>
        	<tr> 
          		<td class="need" width="110"><%= label.getLabelName("L_GroupName") + label.getLabelName("L_Colon") %></td>
          		<td> 
            		<input type="text" name="groupname" size="30" value="<%=JspHelper.filterNull( orgGroupName)%>" isnull="N" label="<%= message.getMessageDesc("VALUE_NOT_NULL",  label.getLabelName("L_GroupName",false)) %>">
          		</td>
        	</tr>
        	<tr>
        		<td class="td-text" width="110"><%= label.getLabelName("L_Department") + label.getLabelName("L_Colon") %></td>
        		<%if(!parentId.equals("")){ %>
        		<td><custom:write property="deptname" name="orggrpinfo" nbsp="true"/></td>
        		<custom:hidden property="deptid" name="orggrpinfo"/>
        		<%}else{
        			boolean deptDisabled = true;
        			if(isbottom.equals("Y"))deptDisabled = false;
        		%>
        		<td><custom:select optionInnerTextKey="deptname" optionsName="alldepts" optionValueKey="deptid" property="deptid" name="orggrpinfo" defaultValue="--------" defaultValueCost=" " disabled="<%=deptDisabled %>"/></td>
        		<%} %>
        	</tr>
        	<tr> 
          		<td class="td-text" width="110"><%= label.getLabelName("L_Description") + label.getLabelName("L_Colon") %> </td>
          		<td> 
            		<input type="text" name="groupdesc" size="70" value="<%=JspHelper.filterNull( orgGroupDesc)%>">
          		</td>
        	</tr>
        	<tr>
        		<input type="hidden" name="parentgroupid" value="<%=JspHelper.filterNull( parentId)%>">
          		<td class="td-text" height="13" width="110"><%= label.getLabelName("L_ParentGroup") + label.getLabelName("L_Colon") %></td>
          		<td><input type="text" name="parentgroupname" value="<%=JspHelper.filterNull( parentName)%>" readonly></td>
        	</tr>
        	</table>
    	</td>
  	</tr>
  	<tr> 
    	<td class="summary_top"></td>
  	</tr>
  	<tr> 
    	<td class="td_center"><a onclick="page_done()"><custom:button type="1" label="L_Finish" imgsrc="finish.gif" border="0" style="width:60"/></a></td>
  	</tr>
	</table>
</form>
</body>
</html>


